/**
 * cms-framework.com.chsimple.cms.framework.interceptor.SecurityInterceptor.java
 * @author chsimple
 * 2013-10-20 下午12:42:22
 */
package com.chsimple.cms.security.interceptor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.interceptor.Interceptor;

/**
 * @author chsimple
 * 
 */
public class SecurityInterceptor implements Interceptor {

	/**
	 * 
	 */
	private static final long serialVersionUID = -9218825378875326820L;

	private static Logger logger = LoggerFactory
			.getLogger(SecurityInterceptor.class);

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.opensymphony.xwork2.interceptor.Interceptor#destroy()
	 */
	public void destroy() {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.opensymphony.xwork2.interceptor.Interceptor#init()
	 */
	public void init() {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony
	 * .xwork2.ActionInvocation)
	 */
	public String intercept(ActionInvocation invocation) throws Exception {
		ActionProxy actionProxy = invocation.getProxy();
		String nameSpace = actionProxy.getNamespace();
		String actionName = actionProxy.getActionName();
		String method = actionProxy.getMethod();
		String accessUrl = nameSpace + "/" + actionName + "!" + method;
		logger.debug(accessUrl + " - begin " + System.nanoTime());
		logger.debug(accessUrl + " - end " + System.nanoTime());
		return invocation.invoke();
	}

}
